#pragma once

#include "Request.h"
#include "Manager.h"

#define SERVER_PRODUCTION_TIME 2

enum ServerGroup
{
	ServerGroupNoPaper,
	ServerGroupNoTobacco,
	ServerGroupNoMatch
};

class Server
{
protected:
	HANDLE m_hStateMutex;
	HANDLE m_hProcessSemaphore;
	Manager* m_pManager;

	bool m_bExit;

	int m_iLastResourceSelection;

	bool m_bResourcesAvailability[NUM_RESOURCE_TYPES];

public:
	Server(Manager *pManager, ServerGroup eGroup);
	~Server();

	void Process();
	inline HANDLE GetProcessSemaphore() { return m_hProcessSemaphore; }

	void RunThread();

	static DWORD WINAPI ThreadFunction(LPVOID param);

	void Stop();
	bool IsStopped();
};

